import {get, post} from './axiosInstance';
// @ts-ignore
import {getCustomers} from '../../client/src/app/core/data.service'

/*
* "arounddeal_id": "v4hrdxoscw",
                "name_first": "Abdel Rahman",
                "name_last": "Ibdah",
                "name_full": "Abdel Rahman Ibdah",
                "job_title": "Service Manager",
                "email_business": "",
                "email_direct": "******@gmail.com",
                "arounddeal_company_id": "t9abgdgjwp",
                "company_name": "Volvo CAR Kuwait"
* */
interface peopleInfo {

    count: number;
    list: {
        arounddeal_id: string;
        name_first: string;
        name_last: string;
        name_full: string;
        job_title: string;
        email_business: string;
        email_direct: string;
        arounddeal_company_id: string;
        company_name: string;
    }[];
}

// 写一个获取arounddeal的人员信息的方法，返回是一个数组，使用get方法
export async function getaccountInfo(): Promise<peopleInfo> {
    return await get<peopleInfo>('https://api.arounddeal.com/v2/account');
}

// getPeopleInfo()
//使用getPeopleInfo方法
// getPeopleInfo().then(
//     (info) => {
//         console.log(info.count);
//     }
// )

//写一个获取arounddeal的人员信息的方法，返回是一个数组，使用post方法
export async function getPeopleInfo(): Promise<peopleInfo> {
    //传入json参数
    console.log('getPeopleInfo 开始');


    let lala = await post<{ data: peopleInfo }>('https://api.arounddeal.com/v2/people/search',
        {
            "industry_id": [
                "48"
            ],
            "country_code": [
                "kw"
            ],
            // "contact_must_contain":"a.morais@mushrif.com",
            "page": 1,
            "pageSize": 7
        }
    );
    console.log(lala.data.count);
    let haha = getCustomers()
    //修改lala的list数据
    lala.data.list = lala.data.list.map((item) => {
        return {...item, email: "yilegel@gmail.com", phone: "1234567890"};
    });

    console.log(lala.data.count);
    return lala.data;
}


